﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TaskManage
{
    
    public partial class FormUserChgpwd : Form
    {
        public string uname;

        public FormUserChgpwd()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string upwdOld = this.textBoxOldPasswd.Text.ToString();
            string upwdNew = this.textBoxNewPasswd.Text.ToString();

            int cnt;
            string qstr;
            DBConnect dbConn = new DBConnect();

            qstr = "SELECT Count(uid) FROM users_info WHERE uname = '" + uname + "' AND upasswd = '" + upwdOld + "'";
            cnt = dbConn.Count(qstr);
            if (cnt == 1)
            {
                qstr = "UPDATE users_info SET upasswd = '" + upwdNew + "' WHERE uname = '" + uname + "'";
                dbConn.Update(qstr);
                MessageBox.Show("密码修改成功！", "提示");
            }
            else
            {
                MessageBox.Show("原密码错误，无法修改密码！", "提示");
                return;
            }
        }
    }
}
